package com.touchstone.cloudpacs.request;

import com.touchstone.cloudpacs.common.validate.Insert;
import com.touchstone.cloudpacs.common.validate.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @Description : 新增/编辑用户参数封装
 * @Author : hunter
 * @Date: 2019-07-11 19:35
 * @Version: 1.0
 **/
@Getter
@Setter
@ToString
@ApiModel("新增用户信息")
public class UserRequest {

    /**
     * id
     */
    @ApiModelProperty("id")
    @NotBlank(message = "ID不能为空", groups = Update.class)
    private String id;

    /**
     * 用户名
     */
    @ApiModelProperty("用户名")
    @NotNull(message = "用户名不能为空", groups = {Insert.class, Update.class})
    private String userName;

    /**
     * 密码
     */
    @ApiModelProperty("密码")
    @NotBlank(message = "密码不能为空", groups = {Insert.class, Update.class})
    @Length(message = "密码长度为6至20位", max = 20, min = 6, groups = {Insert.class, Update.class})
    @Pattern(regexp = "^[0-9a-zA-Z!@#$%^&*_]+$", message = "密码必须是数字、字母或者 !@#$%^&*_ 字符组成", groups = {Insert.class, Update.class})
    private String password;

    /**
     * 联系方式
     */
    @ApiModelProperty("手机号")
    @NotNull(message = "手机号不能为空", groups = {Insert.class, Update.class})
    @Pattern(message = "请录入正确手机号", regexp = "^[1][3,4,5,7,8][0-9]{9}$", groups = {Insert.class, Update.class})
    private String phone;

    /**
     * 邮箱地址
     */
    @ApiModelProperty("邮箱地址")
    @Pattern(message = "请录入正确邮箱地址", regexp = "^([a-z0-9A-Z]+[-|\\.|_]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$", groups = {Insert.class, Update.class})
    private String email;

}
